/*
 * DetailsAction.java
 *
 * Created on 4 marzec 2007, 17:10
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package arocms.signin;

import arocms.business.User;
import arocms.business.UserDAO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.log4j.Logger;

/**
 *
 * @author arek
 */
public class DetailsAction extends Action{
    
    private static final String SUCCESS = "success";
    private static final String FAILURE = "failure";
    private Logger log = Logger.getLogger(this.getClass());
    
    /** Creates a new instance of DetailsAction */
    public DetailsAction() {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        log.debug("--> execute");
        String id = request.getParameter("id");
        Long pk = null;
        try {
            pk = new Long(id);
        } catch (Exception ex) {
            ex.printStackTrace();
            return mapping.findForward(FAILURE);
        }
        User user = new UserDAO().find(pk);
        request.setAttribute("User", user);
        log.debug("<-- execute");
        return mapping.findForward(SUCCESS);
    }
    
}
